package com.godpaper.as9.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.godpaper.as9.bussiness.delegates.AlbumDelegate;
	import com.godpaper.as9.events.TryCreateAlbumEvent;
	import com.godpaper.as9.model.AlbumModelLocator;
	
	import mx.rpc.IResponder;

	public class TryCreateAlbumCommand extends CommandBase implements ICommand, IResponder
	{
		private var delegate:AlbumDelegate;
		private var tryCreateAlbumEvent:TryCreateAlbumEvent;
		private var albumModel:AlbumModelLocator = AlbumModelLocator.getInstance();
		public function TryCreateAlbumCommand()
		{
			super();
			delegate = new AlbumDelegate(this);
		}
		
		override public function execute(event:CairngormEvent):void
		{
			tryCreateAlbumEvent = TryCreateAlbumEvent(event);
			delegate.create( [ tryCreateAlbumEvent.simpleAlbum.cno,
								tryCreateAlbumEvent.simpleAlbum.name,
								tryCreateAlbumEvent.simpleAlbum.description,
								tryCreateAlbumEvent.simpleAlbum.creator]);
		}
		
		override public function result(data:Object):void
		{
			trace(data.result.info);
		}
	}
}